package br.com.upcoder.fguard.client.presenter;

import br.com.upcoder.fguard.client.shared.Budget;

import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Widget;

public class AddDebtPresenter implements Presenter {
	private HandlerManager eventBus;
	private Display display;

	public AddDebtPresenter(HandlerManager eventBus, Display display) {
		this.eventBus = eventBus;
		this.display = display;
	}

	public AddDebtPresenter(HandlerManager eventBus, Display display,
			Budget budget) {
		this(eventBus, display);
		this.display.setBudgetCode(budget.getCode());
		this.display.setBudgetName(budget.getName());
	}

	@Override
	public void go(HasWidgets container) {
		container.clear();
		container.add(display.asWidget());
	}

	public interface Display {
		Widget asWidget();

		void setBudgetName(String name);

		void setBudgetCode(Integer code);
	}
}
